package TestsBuxfer;

import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * Created with IntelliJ IDEA.
 * User: C13T
 * Date: 12.07.13
 * Time: 20:47
 * To change this template use File | Settings | File Templates.
 */
public class TestMenuFunc {
    protected WebDriver driver;

    public class TestLogin extends BasicTest{
       /* @BeforeTest

        public void iniDriver(){
           // String browserName = PropertyLoader.loadProperty("browser.name");
           // driver = WebDriverFactory.createDriver(browserName);
           // driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
            driver = new FirefoxDriver();
            driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);
        }   */
        @Test
        public void Test1() {
            TestsBuxfer.LoginPage loginAttempt = new LoginPage(driver);
            loginAttempt.login();
            if (!"https://www.buxfer.com/slogin".equals(driver.getCurrentUrl())){
                //Other case we could navigate to login page but after logging out
                throw new IllegalStateException("This is not the login page");
            }

            TestsBuxfer.HomePage NavigateSummary = new HomePage(driver);
            NavigateSummary.SummaryPage();
            NavigateSummary.CheckContent();
            Assert.assertTrue(driver.getCurrentUrl().equals("https://www.buxfer.com/home#/home"));

            TestsBuxfer.AddTransaction NavigateTrans = new AddTransaction(driver);
            NavigateTrans.TransPage();
            NavigateTrans.CheckContent();
            Assert.assertTrue(driver.getPageSource().contains("tabTitle selected"));

            TestsBuxfer.Reports NavigateReports = new Reports(driver);
            NavigateReports.ReportsPage();
            NavigateReports.CheckContent();
            Assert.assertTrue(driver.getPageSource().contains("tabTitle selected"));

            TestsBuxfer.Budgets NavigateBudgets = new Budgets(driver);
            NavigateBudgets.BudgetsPage();
            NavigateBudgets.CheckContent();
            Assert.assertTrue(driver.getCurrentUrl().equals("https://www.buxfer.com/home#/budgets"));

            TestsBuxfer.Reminders NavigateReminders = new Reminders(driver);
            NavigateReminders.RemindersPage();
            NavigateReminders.CheckContent();
            Assert.assertTrue(driver.getPageSource().contains("tabTitle selected"));

            TestsBuxfer.Forecast NavigateForecast = new Forecast(driver);
            NavigateForecast.ForecastPage();
            NavigateForecast.CheckContent();
            Assert.assertTrue(driver.getPageSource().contains("tabTitle selected"));

            TestsBuxfer.Payments NavigatePayments = new Payments(driver);
            NavigatePayments.PaymentsPage();
            NavigatePayments.CheckContent();
            Assert.assertTrue(driver.getCurrentUrl().equals("https://www.buxfer.com/home#/payments"));
        }
    }
}

